<?php
ob_start();
session_start();
set_magic_quotes_runtime(1);

//=====================================================language=============================================

if($_SESSION['langname']=="")
{
	$language_url="languages/"."english".'/language.php';
	//$langid='1';
}
else
{
	$language_url="languages/".$_SESSION['langname'].'/language.php';
	//$langid=$_SESSION['langId'];
}
include_once("$language_url");


//======================================================End============================================
if($_SESSION['siteuserId']!='')
{
	echo '<script>window.location="main_redirect.php";</script>';
}

include("headerStart.php");
include_once("UserIncludes/DbConfig.php");
include_once("UserIncludes/site_specific_function.php");


if($_POST['mode']=="login")
{

 	login();
}
else
{
//main_content("main();");
main();
}


function login()
{

$REMEmber=$_REQUEST['RememberMe'];

$username=$_REQUEST['uname'];
$PASSword=$_REQUEST['password'];
	$login_sql="SELECT *  FROM ".SITEUSER." WHERE username='".mysql_escape_string($_REQUEST['uname'])."' AND password='".md5(mysql_escape_string($_REQUEST['password']))."' ";
//echo $login_sql;
		$login_rs=mysql_query($login_sql) or die(mysql_error());
		if(mysql_num_rows($login_rs)>0)
		{
				$login_row=mysql_fetch_array($login_rs);
				$_SESSION['siteuserId'] = $login_row['siteuserId'];
				$_SESSION['username']=$login_row['username'];
				$_SESSION['fName']=$login_row['fName'];
				$_SESSION['lName']=$login_row['lName'];
				$_SESSION['email']=$login_row['email'];
				$_SESSION['registrationDate']=$login_row['registrationDate'];
				$_SESSION['company']=$login_row['company'];
				$_SESSION['time']=time();

				if(isset($REMEmber)=='Y')
					{
					setcookie('REMEMBERUSER_NAME',$username,time() + (int)(3*24*3600));
					setcookie('REMEMBERUSER_PASS',$PASSword,time() + (int)(3*24*3600));
					}
				if(isset($REMEmber)=='')
					{
					setcookie('REMEMBERUSER_NAME','',time()-3*24*3600);
					setcookie('REMEMBERUSER_PASS','',time()-3*24*3600);
					}

			//header("Location:main_redirect.php");
			echo '<script>window.location="main_redirect.php";</script>';
			

		}
		else
		{
		 $new_msg=MSG_g;
		 $GLOBALS['msg']= $new_msg;
		
		}
//main_content("main();");
main();
}
function main()
{
//  if($_SESSION['siteuserId']!='') 
// 	{ 
// include_once("main_redirect.php");
// 	
// 	}
// else 	
// 	{ 
// if($_SESSION['siteuserId']=='')
// 	{
include_once("middle_log.php");
	
 	//}

if($_SESSION['langname']=="")
{
	
	$langid='1';
	$advertisepageId='5';
	$publisherpageId='7';
}
else
{
	
	$langid=$_SESSION['langId'];
	$advertisepageId='6';
	$publisherpageId='8';
}

//echo "SELECT * FROM ".STATICPAGE." where pageId='".$advertisepageId."' and langId='".$langid."'";
$sqlAdvertiser=mysql_query("SELECT * FROM ".STATICPAGE." where pageId='".$advertisepageId."' and langId='".$langid."'");
$fetAdvertiseval=mysql_fetch_array($sqlAdvertiser);
$adverTitle=$fetAdvertiseval['pageName'];
$adverDes=$fetAdvertiseval['contents'];


$sqlPublisher=mysql_query("SELECT * FROM ".STATICPAGE." where pageId='".$publisherpageId."' and langId='".$langid."'");
$fetPublisherval=mysql_fetch_array($sqlPublisher);
$publiTitle=$fetPublisherval['pageName'];
$publiDes=$fetPublisherval['contents'];

// if($_SESSION['siteuserId']=='')
// 	{
		?> 

<table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top"></td>
              </tr>
              <tr>
                <td valign="top"><img src="images/spacer.gif" alt="" width="10" height="8"></td>
              </tr>
              <tr>
                <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="49%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="15"><img src="images/BoxTopLeftCor.jpg" alt="" width="16" height="15"></td>
                                      <td class="BoxtopBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                      <td width="16"><img src="images/BoxToprightCor.jpg" alt="" width="16" height="15"></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td class="BoxLeftSideBg">&nbsp;</td>
                                      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td class="BoxTitleBlue"><?php echo $adverTitle; ?></td>
                                          </tr>
                                          <tr>
                                            <td><img src="images/spacer.gif" alt="" width="10" height="8"></td>
                                          </tr>
                                          <tr>
                                            <td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
                                              <tr>
                                                <td class="BoxContent"><?php echo $adverDes; ?></td>
                                              </tr>
                                            </table></td>
                                          </tr>
                                      </table></td>
                                      <td class="BoxRightSideBg">&nbsp;</td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="16"><img src="images/BoxBottomLeftCor.jpg" alt="" width="16" height="15"></td>
                                      <td class="BoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                      <td width="16"><img src="images/BoxBottomrightCor.jpg" alt="" width="16" height="15"></td>
                                    </tr>
                                </table></td>
                              </tr>
                            </table></td>
                            <td width="1%" valign="top">&nbsp;</td>
                            <td width="49%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="15"><img src="images/BoxTopLeftCor.jpg" alt="" width="16" height="15"></td>
                                      <td class="BoxtopBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                      <td width="16"><img src="images/BoxToprightCor.jpg" alt="" width="16" height="15"></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td class="BoxLeftSideBg">&nbsp;</td>
                                      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td class="BoxTitleGreen"><?php echo $publiTitle; ?></td>
                                          </tr>
                                          <tr>
                                            <td><img src="images/spacer.gif" alt="" width="10" height="8"></td>
                                          </tr>
                                          <tr>
                                            <td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
                                              <tr>
                                                <td class="BoxContent"><?php echo $publiDes; ?></td>
                                              </tr>
                                            </table></td>
                                          </tr>
                                      </table></td>
                                      <td class="BoxRightSideBg">&nbsp;</td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="16"><img src="images/BoxBottomLeftCor.jpg" alt="" width="16" height="15"></td>
                                      <td class="BoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                      <td width="16"><img src="images/BoxBottomrightCor.jpg" alt="" width="16" height="15"></td>
                                    </tr>
                                </table></td>
                              </tr>
                            </table></td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><img src="images/spacer.gif" alt="" width="10" height="6"></td>
                      </tr>
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="15"><img src="images/BoxTopLeftCor.jpg" alt="" width="16" height="15"></td>
                                  <td class="BoxtopBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                  <td width="16"><img src="images/BoxToprightCor.jpg" alt="" width="16" height="15"></td>
                                </tr>
                            </table></td>
                          </tr>
                          <tr>
<?php
		$sqlbanner=mysql_query("select * from ".SITEBANNER."");
		$fetchval=mysql_fetch_array($sqlbanner);
		if($fetchval['bannerImage']=='' || !file_exists('admin/banner_image_thumb/'.$fetchval['bannerImage']))
				$bannerimagePath = '<img border="0" src="admin/banner_image/no_image.jpg" height="81" width="482" />';
			else
				$bannerimagePath = '<img border="0" src="admin/banner_image_thumb/'.$fetchval['bannerImage'].'" height="62" width="470"/>';
	?>
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td class="BoxLeftSideBg">&nbsp;</td>
                                  <td align="center"><?php echo $bannerimagePath; ?></td>
                                  <td class="BoxRightSideBg">&nbsp;</td>
                                </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="16"><img src="images/BoxBottomLeftCor.jpg" alt="" width="16" height="15"></td>
                                  <td class="BoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                                  <td width="16"><img src="images/BoxBottomrightCor.jpg" alt="" width="16" height="15"></td>
                                </tr>
                            </table></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                    <td width="6" valign="top">&nbsp; </td>
                    <td width="314" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="15"><img src="images/BoxTopLeftCor.jpg" alt="" width="16" height="15"></td>
                              <td class="BoxtopBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                              <td width="16"><img src="images/BoxToprightCor.jpg" alt="" width="16" height="15"></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td class="BoxLeftSideBg">&nbsp;</td>
                              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td class="BoxTitlePink">Latest News</td>
                                </tr>
                                <tr>
                                  <td><img src="images/spacer.gif" alt="" width="10" height="8"></td>
                                </tr>
					<?php
					$sqlFetchNews=mysql_query("select * from ".SITENEWS." order by rand() limit 0,2");
					$count='1';
					while($fetcVal=mysql_fetch_array($sqlFetchNews))
					{
						$newsTitle=$fetcVal['newsTitle'];
						$newsDesc=$fetcVal['newsDetails'];
				?>
                                <tr>
                                  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td height="20" class="NewsTitleBold"><span class="NewsListingBlue"><?php echo $count; ?></span> &nbsp;<?php echo $newsTitle; ?></td>
                                    </tr>
                                    <tr>
                                      <td class="BoxContent"><?php echo $newsDesc; ?></td>
                                    </tr>
                                  </table></td>
                                </tr>

                                <tr>
                                  <td><img src="images/spacer.gif" alt="" width="10" height="8"></td>
                                </tr>
				<?php
					$count++;
					}
				  ?>
                                <tr>
                                  <td align="right"><a href="#" class="MoreButton">More...</a></td>
                                </tr>
                              </table></td>
                              <td class="BoxRightSideBg">&nbsp;</td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="16"><img src="images/BoxBottomLeftCor.jpg" alt="" width="16" height="15"></td>
                              <td class="BoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="15"></td>
                              <td width="16"><img src="images/BoxBottomrightCor.jpg" alt="" width="16" height="15"></td>
                            </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
            </table>
            
<?php


}
        include("footerStart.php");
		?> 